package day05;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Description: 多条流的合并
 *              所有流中的事件类型必须是一样的
 * @Author: ZYX
 * @Date: 2022/2/15 09:13
 * @Version: 1.0
 */
public class Demo06 {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        DataStreamSource<Integer> stream1 = env.fromElements(1, 2);
        DataStreamSource<Integer> stream2 = env.fromElements(3, 4);
        DataStreamSource<Integer> stream3 = env.fromElements(5, 6);

        DataStream<Integer> result = stream1.union(stream2, stream3);
        result.print();

        env.execute();
    }

}
